// 云函数代码
const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})

exports.main = async (event, context) => {
  const res = await cloud.cloudPay.unifiedOrder({
    "body": event.goodsName, //商品名称或描述
    "outTradeNo": "weipengyu" + new Date().getTime(), //订单号，一定要保持唯一性
    "spbillCreateIp": "127.0.0.1", //回调域名，可以不填
    "subMchId": "1510633421", //商户号
    "totalFee": event.totalFee, //支付金额
    "envId": "cloud1-9gca0ubn1408ce51", //环境ID
    "functionName": "pay_cb"
  })
  return res
}